package net.hn.hnms.biz.safety.monitor.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import net.hn.hnms.biz.api.safety.monitor.model.AlarmTrendVo;
import net.hn.hnms.biz.api.safety.monitor.model.KeyAreasVo;
import net.hn.hnms.biz.safety.monitor.domain.dto.DataConfiginfoDto;
import net.hn.hnms.biz.safety.monitor.domain.dto.PointListVO;
import net.hn.hnms.biz.safety.monitor.domain.vo.keyAreasVo;
import net.hn.hnms.biz.safety.monitor.service.SafetyMonitorService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 智呈物联 pan'sx
 * 2022/8/19 10:19
 * 1.0 version
 */
@RestController
@RequestMapping("riskMonitor/idnex")
@Api(value = "首页相关接口", tags = {"首页接口"})
@RequiredArgsConstructor
public class IndexController {
    private final SafetyMonitorService safetyMonitorService;

    @GetMapping("keyAreas")
    @ApiOperation("重点区域")
    @AutoSetMineCode
    public R<List<KeyAreasVo>> keyAreas(@ApiParam(value = "区域id", required = true) String areaId,String mineCode) {
        return R.ok(safetyMonitorService.keyAreas(areaId,mineCode));
    }

    @GetMapping("alarmTrend")
    @ApiOperation("co与CH4报警趋势")
    @AutoSetMineCode
    public R<AlarmTrendVo> alarmTrend(@ApiParam(value = "月|周") String type,String mineCode) {
        return R.ok(safetyMonitorService.indexAlarmTrend(type,mineCode));
    }

    @GetMapping("getWorkFace")
    @ApiOperation("工作面")
    @AutoSetMineCode
    public R<List<String>> getWorkFace(String mineCode) {
        return R.ok(safetyMonitorService.getWorkFace(mineCode));
    }

    @GetMapping("getkeyAreasInfoByWorkFace")
    @ApiOperation("根据工作面获取重点区域信息")
    @AutoSetMineCode
    public R<List<keyAreasVo>> getkeyAreasInfoByWorkFace(@ApiParam(value = "工作面名称", required = true) String workFaceName, String mineCode) {
        List<keyAreasVo> list = safetyMonitorService.getkeyAreasInfoByWorkFace(workFaceName, mineCode);
        return R.ok(list);
    }

    @GetMapping("getPointListByPointType")
    @ApiOperation("根据测点类型获取所有测点")
    @AutoSetMineCode
    public R<List<PointListVO>> getPointListByPointType(@ApiParam(value = "测点类型名称", required = true) String pointTypeName, String mineCode) {
        List<PointListVO> list = safetyMonitorService.getPointListByPointType(pointTypeName, mineCode);
        return R.ok(list);
    }
    @PutMapping("upDataConfiginfo")
    @ApiOperation("更新关键区域测点配置信息")
    @AutoSetMineCode
    public R upDataConfiginfo(String mineCode ,@RequestBody DataConfiginfoDto dataConfiginfoDto) {
        dataConfiginfoDto.setMineCode(mineCode);
        Boolean isTrue = safetyMonitorService.upDataConfiginfo(dataConfiginfoDto);
        if (isTrue) {
            return R.ok();
        }
        return R.fail();
    }


}
